package com.zy.Conterller;


import com.zy.pojo.Permission;
import com.zy.pojo.Staff;
import com.zy.service.PermissionService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;


@Controller
public class IndexConunt {
    @Resource
    private PermissionService permissionService;
    @GetMapping("/index")
    public String index(Model model){

       Subject subject = SecurityUtils.getSubject();
        Staff staff = (Staff) subject.getPreviousPrincipals();
        Session session= subject.getSession();
        session.setAttribute("loginUser",staff);

        List<Permission> menulist=permissionService.getPerM();
        model.addAttribute("menulist",menulist);
        return "index";

    }
}
